import Vue from 'vue'
import Vuex from 'vuex'
import actions from './actions'
import getters from './getters'
import mutations from './mutations'

import { detectOS } from '@/utils/'
import lstore from '@/plugins/lstore/'

import modules from './module/'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    loginStatus: lstore.hasData('H5_ACCESS_TOKEN'),

    /* 终端信息 */
    BROWSER: detectOS(),

    /* 当前登录用户信息 */
    CURRENTUSER: lstore.getData('H5_CUR_USER') || {},

    /* 定位信息 */
    POSITION: lstore.getData('H5_CURRENT_POSITION') || {},

    /* 用户信息 */
    USERS: lstore.getData('H5_USERS') || {},

    CONFIG: lstore.getData('BOOTSTRAPPERS') || {}
  },
  getters,
  actions,
  mutations,
  modules: {
    ...modules
  }
})
